<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {

	//系统首页
    public function index(){
        //echo 111;die();
        //var_dump(I('post.'));
            header("Content-type:text/html;charset=utf-8");
            require_once("./ThinkPHP/Library/Vendor/WxPayPubHelper/lib/WxPay.Api.php");
            require_once("./ThinkPHP/Library/Vendor/WxPayPubHelper/example/WxPay.JsApiPay.php");
            $tools = new \JsApiPay();
            $openId = $tools->GetOpenid();
            //echo $openId;
     
            //var_dump($trade_info);die();
            //echo $total_price;die();
            //echo 111;die();
            //②、统一下单
            $input = new \WxPayUnifiedOrder();
            $input->SetBody("产品支付");
            $input->SetAttach("产品支付");
            $input->SetOut_trade_no(date("YmdHis", time()));
            $input->SetTotal_fee(1*100);
            $input->SetTime_start(date("YmdHis"));
            $input->SetTime_expire(date("YmdHis", time() + 600));
            $input->SetGoods_tag("test");
            $input->SetNotify_url("http://zhichang666.cn/example/notify.php");
            $input->SetTrade_type("JSAPI");
            $input->SetOpenid($openId);
            $parameter=new \WxPayApi();
            //print_r($input);
            $order = $parameter->unifiedOrder($input);
            //var_dump($order);
            //echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
            //print_r($order);die();
            $jsApiParameters = $tools->GetJsApiParameters($order);
            //获取共享收货地址js函数参数
            $editAddress = $tools->GetEditAddressParameters();
            $this->assign('jsApiParameters',$jsApiParameters);
            $this->assign('editAddress',$editAddress);
            $this->display();
    }
    public function index2(){
        //echo 111;die();
        //var_dump(I('post.'));
            header("Content-type:text/html;charset=utf-8");
            require_once("./ThinkPHP/Library/Vendor/WxPayPubHelper/lib/WxPay.Api.php");
            require_once("./ThinkPHP/Library/Vendor/WxPayPubHelper/example/WxPay.JsApiPay.php");
            $tools = new \JsApiPay();
            $openId = $tools->GetOpenid();
            //echo $openId;
     
            //var_dump($trade_info);die();
            //echo $total_price;die();
            //echo 111;die();
            //②、统一下单
            $input = new \WxPayUnifiedOrder();
            $input->SetBody("产品支付");
            $input->SetAttach("产品支付");
            $input->SetOut_trade_no(date("YmdHis", time()));
            $input->SetTotal_fee(2*100);
            $input->SetTime_start(date("YmdHis"));
            $input->SetTime_expire(date("YmdHis", time() + 600));
            $input->SetGoods_tag("test");
            $input->SetNotify_url("http://zhichang666.cn/example/notify.php");
            $input->SetTrade_type("JSAPI");
            $input->SetOpenid($openId);
            $parameter=new \WxPayApi();
            //print_r($input);
            $order = $parameter->unifiedOrder($input);
            //var_dump($order);
            //echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
            //print_r($order);die();
            $jsApiParameters = $tools->GetJsApiParameters($order);
            //获取共享收货地址js函数参数
            $editAddress = $tools->GetEditAddressParameters();
            $this->assign('jsApiParameters',$jsApiParameters);
            $this->assign('editAddress',$editAddress);
            $this->display();
    }
    public function index3(){
        //echo 111;die();
        //var_dump(I('post.'));
            header("Content-type:text/html;charset=utf-8");
            require_once("./ThinkPHP/Library/Vendor/WxPayPubHelper/lib/WxPay.Api.php");
            require_once("./ThinkPHP/Library/Vendor/WxPayPubHelper/example/WxPay.JsApiPay.php");
            $tools = new \JsApiPay();
            $openId = $tools->GetOpenid();
            //echo $openId;
     
            //var_dump($trade_info);die();
            //echo $total_price;die();
            //echo 111;die();
            //②、统一下单
            $input = new \WxPayUnifiedOrder();
            $input->SetBody("产品支付");
            $input->SetAttach("产品支付");
            $input->SetOut_trade_no(date("YmdHis", time()));
            $input->SetTotal_fee(3.5*100);
            $input->SetTime_start(date("YmdHis"));
            $input->SetTime_expire(date("YmdHis", time() + 600));
            $input->SetGoods_tag("test");
            $input->SetNotify_url("http://zhichang666.cn/example/notify.php");
            $input->SetTrade_type("JSAPI");
            $input->SetOpenid($openId);
            $parameter=new \WxPayApi();
            //print_r($input);
            $order = $parameter->unifiedOrder($input);
            //var_dump($order);
            //echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
            //print_r($order);die();
            $jsApiParameters = $tools->GetJsApiParameters($order);
            //获取共享收货地址js函数参数
            $editAddress = $tools->GetEditAddressParameters();
            $this->assign('jsApiParameters',$jsApiParameters);
            $this->assign('editAddress',$editAddress);
            $this->display();
    }

}